﻿import mx.utils.Delegate;
class cn.eminia.AS2.Ld {
	// [置顶]
	//var LdLd= new cn.eminia.AS2.Ld(ctnr,{scope:this,stt:function(evt){
	//   trace(evt.mc);
	//},pro:function(evt){
	//   trace(evt.per);  
	//   trace(evt.cur);  
	//   trace(evt.ttl);   
	//},ok:function(evt){
	//   trace(evt.mc);  
	//}});
	//LdLd.load('swf1.swf');
	//
	var mc:MovieClip;
	var ld:MovieClipLoader;
	function Ld(mc:MovieClip, obj:Object) {
		if (mc == undefined || mc.constructor != MovieClip) {
			throw ('!! 错误，无加载容器');
		}
		this.mc = mc;
		this.ld = new MovieClipLoader();
		//
		var lis:Object = new Object();
		lis.onLoadStart = Delegate.create(obj.scope, function (mc:MovieClip) {
			obj.stt({mc:mc});
		});
		lis.onLoadProgress = Delegate.create(obj.scope, function (mc:MovieClip, ld:Number, tt:Number) {
			obj.pro({per:Math.round(ld/tt*100), cur:ld, ttl:tt, mc:mc});
		});
		lis.onLoadInit = Delegate.create(obj.scope, function (mc:MovieClip) {
			obj.ok({mc:mc});
		});
		this.ld.addListener(lis);
	}
	function load(url):Void {
		trace('url -> '+url+' ctt -> '+this.mc);
		this.ld.loadClip(url, this.mc);
	}
	function unload():Void {
		this.ld.unloadClip(this.mc);
	}
}
